package com.maiji.cloud.controller.community;

import com.maiji.cloud.controller.BaseController;
import com.maiji.cloud.entities.community.ComMiddleLabel;
import com.maiji.cloud.entities.community.ComMsgInfo;
import com.maiji.cloud.entities.community.ComMsgTransmitRule;
import com.maiji.cloud.request.BaseDataReqDto;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.IdInputDto;
import com.maiji.cloud.request.community.ComMsgTopManInputDto;
import com.maiji.cloud.request.community.ComPubComInputDto;
import com.maiji.cloud.request.community.ComRecsInputDto;
import com.maiji.cloud.request.community.ComSearchInputDto;
import com.maiji.cloud.response.BaseDataResDto;
import com.maiji.cloud.response.BaseMetaResDto;
import com.maiji.cloud.response.BaseOutPutDto;
import com.maiji.cloud.response.BaseResDto;
import com.maiji.cloud.response.community.ComDetailOutputDto;
import com.maiji.cloud.response.community.ComMsgBaseOutputDto;
import com.maiji.cloud.response.community.ComRecsOutputDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/community")
@Api(tags = {"社区"})
public class CommunityController extends BaseController {

    @PostMapping("/publish")
    @ApiOperation("发布动态")
    public BaseOutPutDto<ComRecsOutputDto> publish(@RequestBody BaseInputDto<ComPubComInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/publish", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/msgList")
    @ApiOperation("社区通用列表查询")
    public BaseOutPutDto<List<ComRecsOutputDto>> msgList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/msgList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/detailMsg")
    @ApiOperation("动态详细")
    public BaseOutPutDto<ComDetailOutputDto> detailMsg(@RequestBody BaseInputDto<IdInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/detailMsg", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/focusersBlogList")
    @ApiOperation("关注动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> focusersBlogList(@RequestBody BaseInputDto<ComRecsInputDto> inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/focusersBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/mineBlogList")
    @ApiOperation("我的动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> mineBlogList(@RequestBody BaseInputDto inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/mineBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/userBlogList")
    @ApiOperation("用户动态列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> userBlogList(@RequestBody BaseInputDto<IdInputDto> inputDto,@RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/userBlogList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/searchMsg")
    @ApiOperation("搜索动态")
    public BaseOutPutDto<List<ComRecsOutputDto>> searchMsg(@RequestBody BaseInputDto<ComSearchInputDto> inputDto,
                                                           @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/searchMsg", inputDto, BaseOutPutDto.class);
    }

    /**
     * 管理员删除动态
     * @param inputDto
     * @return
     */
    @PostMapping("/managerDelete")
    @ApiOperation("管理员删除动态")
    public BaseOutPutDto<String>managerDelete(@RequestBody BaseInputDto<IdInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/managerDelete", inputDto, BaseOutPutDto.class);
    }

    /**
     * 动态设置为精选
     * @param inputDto
     * @return
     */
    @PostMapping("/setEssence")
    @ApiOperation("动态设置为精选")
    public BaseOutPutDto<String>setEssence(@RequestBody BaseInputDto<IdInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/setEssence", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/setCase")
    @ApiOperation("动态设置为案例")
    public BaseOutPutDto<String>setCase(@RequestBody BaseInputDto<IdInputDto> inputDto){

        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/setCase", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/topListManager")
    @ApiOperation("管理消息置顶")
    public BaseOutPutDto<String> topListManager(@RequestBody BaseInputDto<ComMsgTopManInputDto>inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/topListManager", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/topList")
    @ApiOperation("社区置顶列表")
    public BaseOutPutDto<List<ComRecsOutputDto>> topList(@RequestBody BaseInputDto inputDto, @RequestHeader("maijiToken")String maijiToken){
        return postForObjectWithToken(maijiToken, REST_URL_PREFIX_COMMUNITY + "/community/topList", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/setIntegral")
    @ApiOperation("设置转发得积分")
    public BaseOutPutDto<String> setIntegral(BaseInputDto<IdInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/setIntegral", inputDto, BaseOutPutDto.class);
    }

    @PostMapping("/cancelIntegral")
    @ApiOperation("取消转发积分")
    public BaseOutPutDto<String> cancelIntegral(BaseInputDto<IdInputDto> inputDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/cancelIntegral", inputDto, BaseOutPutDto.class);
    }

    /**
     * 获取动态列表 - pc
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("/findAllComMsgInfos")
    @ApiOperation("获取动态列表")
    public BaseMetaResDto<List<ComMsgInfo>> findAllComMsgInfos (@RequestBody BaseDataReqDto<ComMsgInfo> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/findAllComMsgInfos", baseDataReqDto, BaseMetaResDto.class);
    }

    /**
     * 编辑动态 - pc
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("/editComMsgInfo")
    @ApiOperation("编辑动态")
    public BaseResDto editComMsgInfo (@RequestBody BaseDataReqDto<ComMsgInfo> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/editComMsgInfo", baseDataReqDto, BaseResDto.class);
    }

    /**
     * 编辑动态标签 - pc
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("/editComMiddleLabel")
    @ApiOperation("编辑动态标签")
    public BaseResDto editComMiddleLabel (@RequestBody BaseDataReqDto<ComMiddleLabel> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/comMidLabel/editComMiddleLabel", baseDataReqDto, BaseResDto.class);
    }

    /**
     * 获取动态详细信息 - pc
     * @param baseDataReqDto
     * @return
     */
    @PostMapping("/findComMsgById")
    @ApiOperation("获取动态详细信息")
    public BaseDataResDto<ComMsgBaseOutputDto> findComMsgById (@RequestBody BaseDataReqDto<String> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/findComMsgById", baseDataReqDto, BaseDataResDto.class);
    }

    /**
     * 获取转发得积分基本规则 - pc
     * @return
     */
    @PostMapping("/findMsgTransmitRule")
    @ApiOperation("获取转发得积分基本规则")
    public BaseDataResDto<ComMsgTransmitRule> findMsgTransmitRule (){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/findMsgTransmitRule", null, BaseDataResDto.class);
    }

    /**
     * 编辑转发得积分基本规则 - pc
     * @return
     */
    @PostMapping("/editComMsgTransmitRule")
    @ApiOperation("编辑转发得积分基本规则")
    public BaseResDto editComMsgTransmitRule (@RequestBody BaseDataReqDto<ComMsgTransmitRule> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/editComMsgTransmitRule", baseDataReqDto, BaseResDto.class);
    }

    /**
     * 获取转发得积分基本规则编辑记录 - pc
     * @return
     */
    @PostMapping("/findAllComMsgTransmitRuleLogs")
    @ApiOperation("获取转发得积分基本规则编辑记录")
    public BaseDataResDto<List<ComMsgTransmitRule>> findAllComMsgTransmitRuleLogs (@RequestBody BaseDataReqDto<List<Date>> baseDataReqDto){
        return restTemplate.postForObject(REST_URL_PREFIX_COMMUNITY + "/community/findAllComMsgTransmitRuleLogs", baseDataReqDto, BaseDataResDto.class);
    }

}
